package com.module.biometric;

import android.app.Activity;
import android.util.Base64;
import android.util.Log;

import javax.crypto.Cipher;

public class ACacheUtils {

    public static void setIV(Activity activity, Cipher cipher) {
        ACache aCache = ACache.get(activity.getApplication().getApplicationContext());
        byte[] iv = cipher.getIV();
        Log.i("test", "设置指纹保存的加密IV: " + Base64.encodeToString(iv, Base64.URL_SAFE));
        aCache.put("iv", Base64.encodeToString(iv, Base64.URL_SAFE));
    }

    public static String getIV(Activity activity, Cipher cipher) {
        byte[] iv = cipher.getIV();
        return Base64.encodeToString(iv, Base64.URL_SAFE);
    }

    public static String getIV(Activity activity) {
        ACache aCache = ACache.get(activity.getApplication().getApplicationContext());
        String ivStr = aCache.getAsString("iv");
        return ivStr;
    }
}
